<%@ Page Title="Product Management" Language="C#" MasterPageFile="~/Admin/AdminDefault.master" AutoEventWireup="true" CodeFile="ManageProducts.aspx.cs" Inherits="Admin_Product_ManageProducts" %>

<asp:Content ID="Content1" ContentPlaceHolderID="mainContent" Runat="Server">
    <h2>Products</h2>
    Select a Product Type:
    <asp:DropDownList ID="ddlProductTypes" runat="server" 
        DataSourceID="ProductTypesDS" DataTextField="Name" 
        DataValueField="ProductTypeId" EnableViewState="false" AutoPostBack="true" 
        AppendDataBoundItems="True">
        <asp:ListItem Selected="True" Value="-1">All</asp:ListItem>
    </asp:DropDownList>
    <asp:ObjectDataSource ID="ProductTypesDS" runat="server" 
        OldValuesParameterFormatString="{0}" SelectMethod="GetProductTypes" 
        TypeName="Ample.BLL.ProductTypeBO" EnableViewState="false"></asp:ObjectDataSource>
    <br />
    <a href="ViewProduct.aspx">New</a>
    <asp:GridView ID="gvProducts" runat="server" DataSourceID="ProductObjDS" 
        AutoGenerateColumns="False" DataKeyNames="ProductId" 
        onrowdatabound="gvProducts_RowDataBound" EnableViewState="False">
        <Columns>
            <asp:TemplateField ShowHeader="False" ItemStyle-Width="13%">
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="False" 
                        CommandName="Select" Text="Select" PostBackUrl='<%#Eval("ProductId","~/Admin/Product/ViewProduct.aspx?ID={0}") %>'></asp:LinkButton> 
                    <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                        CommandName="Delete" Text="Delete"></asp:LinkButton>
                </ItemTemplate>

<ItemStyle Width="13%"></ItemStyle>
            </asp:TemplateField>
            <asp:BoundField DataField="ProductId" HeaderText="ProductId" 
                SortExpression="ProductId" Visible="False" />
            <asp:TemplateField ItemStyle-Width="15%" HeaderText="Product Type" SortExpression="ProductTypeId">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("ProductType.Name") %>'></asp:Label>
                </ItemTemplate>

<ItemStyle Width="15%"></ItemStyle>
            </asp:TemplateField>
            <asp:TemplateField ItemStyle-Width="20%" HeaderText="Name" SortExpression="Name">
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
                </ItemTemplate>

<ItemStyle Width="20%"></ItemStyle>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Price" SortExpression="Price">
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("Price", "{0:c}") %>'></asp:Label>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Right" />
            </asp:TemplateField>
            <asp:TemplateField ItemStyle-Width="20%" HeaderText="Package" SortExpression="Package">
                <ItemTemplate>
                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("Package") %>'></asp:Label>
                </ItemTemplate>

<ItemStyle Width="20%"></ItemStyle>
            </asp:TemplateField>
            <asp:TemplateField ItemStyle-Width="35%" HeaderText="Description" SortExpression="Description">
                <ItemTemplate>
                    <asp:Label ID="Label5" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
                </ItemTemplate>

<ItemStyle Width="35%"></ItemStyle>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    
    <asp:ObjectDataSource ID="ProductObjDS" runat="server" 
        OldValuesParameterFormatString="original_{0}" SelectMethod="GetProductByTypeId" 
        TypeName="Ample.BLL.ProductBO" EnableViewState="False" 
        DataObjectTypeName="Ample.Model.Product" DeleteMethod="DeleteProduct">
        <SelectParameters>
            <asp:ControlParameter ControlID="ddlProductTypes" Name="prodTypeId" 
                PropertyName="SelectedValue" Type="Int32" />
        </SelectParameters>
        
    </asp:ObjectDataSource>
</asp:Content>

